package com.stationbuilding.activity.quality;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;
import com.stationbuilding.R;
import com.stationbuilding.fragment.quality.QualitySelectFragment;

public class QualitySelectActivity extends AppCompatActivity {

    private int id;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_quality_select);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        TextView toolbarTitle = (TextView) findViewById(R.id.toolbar_title);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setResult(RESULT_CANCELED, new Intent());
                finish();
            }
        });
        Intent intent = getIntent();
        toolbarTitle.setText(intent.getStringExtra("toolbar_title"));
        id = intent.getIntExtra("id", 0);

        initEvent();
    }

    private void initEvent() {
        Bundle bundle = new Bundle();
        bundle.putInt("id", id);
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out);
        QualitySelectFragment qualitySelectFragment = new QualitySelectFragment();
        qualitySelectFragment.setArguments(bundle);
        ft.replace(R.id.content, qualitySelectFragment);
        ft.commit();
    }
}
